<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>users &mdash; GOZERWAVE v0.1 BETA documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.1 BETA',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="GOZERWAVE v0.1 BETA documentation" href="../index.html" />
    <link rel="next" title="gozerlib.persist" href="persist/index.html" />
    <link rel="prev" title="tests" href="tests.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="persist/index.html" title="gozerlib.persist"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tests.html" title="tests"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="users">
<h1>users<a class="headerlink" href="#users" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-gozerlib.users">
<h2>description<a class="headerlink" href="#module-gozerlib.users" title="Permalink to this headline">¶</a></h2>
<p>bot users</p>
<dl class="class">
<dt id="gozerlib.users.GozerUser">
<em class="property">class </em><tt class="descclassname">gozerlib.users.</tt><tt class="descname">GozerUser</tt><big>(</big><em>parent=None</em>, <em>key_name=None</em>, <em>_app=None</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUser" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref docutils literal"><span class="pre">google.appengine.ext.db.Expando</span></tt></p>
<p>gozerwave users model.</p>
<dl class="attribute">
<dt id="gozerlib.users.GozerUser.email">
<tt class="descname">email</tt><a class="headerlink" href="#gozerlib.users.GozerUser.email" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.name">
<tt class="descname">name</tt><a class="headerlink" href="#gozerlib.users.GozerUser.name" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.password">
<tt class="descname">password</tt><a class="headerlink" href="#gozerlib.users.GozerUser.password" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.permits">
<tt class="descname">permits</tt><a class="headerlink" href="#gozerlib.users.GozerUser.permits" title="Permalink to this definition">¶</a></dt>
<dd><p>A property that stores a list of strings.</p>
<p>A shorthand for the most common type of ListProperty.</p>
</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.perms">
<tt class="descname">perms</tt><a class="headerlink" href="#gozerlib.users.GozerUser.perms" title="Permalink to this definition">¶</a></dt>
<dd><p>A property that stores a list of strings.</p>
<p>A shorthand for the most common type of ListProperty.</p>
</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.statuses">
<tt class="descname">statuses</tt><a class="headerlink" href="#gozerlib.users.GozerUser.statuses" title="Permalink to this definition">¶</a></dt>
<dd><p>A property that stores a list of strings.</p>
<p>A shorthand for the most common type of ListProperty.</p>
</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUser.userhosts">
<tt class="descname">userhosts</tt><a class="headerlink" href="#gozerlib.users.GozerUser.userhosts" title="Permalink to this definition">¶</a></dt>
<dd><p>A property that stores a list of strings.</p>
<p>A shorthand for the most common type of ListProperty.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="gozerlib.users.GozerUserhost">
<em class="property">class </em><tt class="descclassname">gozerlib.users.</tt><tt class="descname">GozerUserhost</tt><big>(</big><em>parent=None</em>, <em>key_name=None</em>, <em>_app=None</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUserhost" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref docutils literal"><span class="pre">google.appengine.ext.db.Expando</span></tt></p>
<p>used to lookup userhost based on name.</p>
<dl class="attribute">
<dt id="gozerlib.users.GozerUserhost.name">
<tt class="descname">name</tt><a class="headerlink" href="#gozerlib.users.GozerUserhost.name" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

<dl class="attribute">
<dt id="gozerlib.users.GozerUserhost.userhost">
<tt class="descname">userhost</tt><a class="headerlink" href="#gozerlib.users.GozerUserhost.userhost" title="Permalink to this definition">¶</a></dt>
<dd>A textual property, which can be multi- or single-line.</dd></dl>

</dd></dl>

<dl class="class">
<dt id="gozerlib.users.GozerUsers">
<em class="property">class </em><tt class="descclassname">gozerlib.users.</tt><tt class="descname">GozerUsers</tt><a class="headerlink" href="#gozerlib.users.GozerUsers" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a title="(in Python v2.7)" class="reference external" href="http://docs.python.org/dev/library/functions.html#object"><tt class="xref docutils literal"><span class="pre">object</span></tt></a></p>
<p>google datbase engine backed users.</p>
<dl class="method">
<dt id="gozerlib.users.GozerUsers.add">
<tt class="descname">add</tt><big>(</big><em>name</em>, <em>userhosts</em>, <em>perms</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.add" title="Permalink to this definition">¶</a></dt>
<dd><p>add an user. session argument is provided by &#64;trans</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>name</em> (string) &#8211; name of the user</li>
<li><em>userhosts</em> (list .. list of userhosts) &#8211; userhosts to add</li>
<li><em>perms</em> (list .. list of permissions) &#8211; the permissions to add</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.addperm">
<tt class="descname">addperm</tt><big>(</big><em>userhost</em>, <em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.addperm" title="Permalink to this definition">¶</a></dt>
<dd>add the specified perm to the userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.addpermit">
<tt class="descname">addpermit</tt><big>(</big><em>userhost</em>, <em>permit</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.addpermit" title="Permalink to this definition">¶</a></dt>
<dd>add the given [who, what] permit to the given userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.addstatus">
<tt class="descname">addstatus</tt><big>(</big><em>userhost</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.addstatus" title="Permalink to this definition">¶</a></dt>
<dd>add status to given userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.adduseremail">
<tt class="descname">adduseremail</tt><big>(</big><em>name</em>, <em>email</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.adduseremail" title="Permalink to this definition">¶</a></dt>
<dd>add email to specified user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.adduserhost">
<tt class="descname">adduserhost</tt><big>(</big><em>name</em>, <em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.adduserhost" title="Permalink to this definition">¶</a></dt>
<dd>add userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.adduserperm">
<tt class="descname">adduserperm</tt><big>(</big><em>name</em>, <em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.adduserperm" title="Permalink to this definition">¶</a></dt>
<dd>add permission.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.adduserpermit">
<tt class="descname">adduserpermit</tt><big>(</big><em>name</em>, <em>who</em>, <em>permit</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.adduserpermit" title="Permalink to this definition">¶</a></dt>
<dd>add (who, what) permit tuple to specified user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.adduserstatus">
<tt class="descname">adduserstatus</tt><big>(</big><em>name</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.adduserstatus" title="Permalink to this definition">¶</a></dt>
<dd>add status to given user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.allowed">
<tt class="descname">allowed</tt><big>(</big><em>userhost</em>, <em>perms</em>, <em>log=True</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.allowed" title="Permalink to this definition">¶</a></dt>
<dd><p>check if user with userhosts is allowed to execute perm command.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><em>userhost</em> (string) &#8211; userhost to check</li>
<li><em>perms</em> (list) &#8211; the permissions to check</li>
<li><em>log</em> (boolean) &#8211; whether the check should be logged</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list .. list of matching permissions or None</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delallemail">
<tt class="descname">delallemail</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delallemail" title="Permalink to this definition">¶</a></dt>
<dd>Delete all emails of the specified user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delemail">
<tt class="descname">delemail</tt><big>(</big><em>userhost</em>, <em>email</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delemail" title="Permalink to this definition">¶</a></dt>
<dd>delete email from userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delete">
<tt class="descname">delete</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delete" title="Permalink to this definition">¶</a></dt>
<dd>delete user with name.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delperm">
<tt class="descname">delperm</tt><big>(</big><em>userhost</em>, <em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delperm" title="Permalink to this definition">¶</a></dt>
<dd>delete perm from userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delpermall">
<tt class="descname">delpermall</tt><big>(</big><em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delpermall" title="Permalink to this definition">¶</a></dt>
<dd>delete permission from all users.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delpermit">
<tt class="descname">delpermit</tt><big>(</big><em>userhost</em>, <em>permit</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delpermit" title="Permalink to this definition">¶</a></dt>
<dd>delete permit from userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.delstatus">
<tt class="descname">delstatus</tt><big>(</big><em>userhost</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.delstatus" title="Permalink to this definition">¶</a></dt>
<dd>delete status from userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.deluseremail">
<tt class="descname">deluseremail</tt><big>(</big><em>name</em>, <em>email</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.deluseremail" title="Permalink to this definition">¶</a></dt>
<dd>delete email.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.deluserhost">
<tt class="descname">deluserhost</tt><big>(</big><em>name</em>, <em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.deluserhost" title="Permalink to this definition">¶</a></dt>
<dd>delete the userhost entry.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.deluserperm">
<tt class="descname">deluserperm</tt><big>(</big><em>name</em>, <em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.deluserperm" title="Permalink to this definition">¶</a></dt>
<dd>delete permission.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.deluserpermit">
<tt class="descname">deluserpermit</tt><big>(</big><em>name</em>, <em>permit</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.deluserpermit" title="Permalink to this definition">¶</a></dt>
<dd>delete permit.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.deluserstatus">
<tt class="descname">deluserstatus</tt><big>(</big><em>name</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.deluserstatus" title="Permalink to this definition">¶</a></dt>
<dd>delete the status from the given user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.exists">
<tt class="descname">exists</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.exists" title="Permalink to this definition">¶</a></dt>
<dd><p>see if user with &lt;name&gt; exists.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>name</em> &#8211; name of the user</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">boolean</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getemail">
<tt class="descname">getemail</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getemail" title="Permalink to this definition">¶</a></dt>
<dd>return the email of the specified userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.gethosts">
<tt class="descname">gethosts</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.gethosts" title="Permalink to this definition">¶</a></dt>
<dd>return the userhosts of the user associated with the 
specified userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getname">
<tt class="descname">getname</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getname" title="Permalink to this definition">¶</a></dt>
<dd>get name of user belonging to &lt;userhost&gt;.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getpermits">
<tt class="descname">getpermits</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getpermits" title="Permalink to this definition">¶</a></dt>
<dd>return permits of the specified userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getperms">
<tt class="descname">getperms</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getperms" title="Permalink to this definition">¶</a></dt>
<dd>return permissions of user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getpermusers">
<tt class="descname">getpermusers</tt><big>(</big><em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getpermusers" title="Permalink to this definition">¶</a></dt>
<dd>return all users that have the specified perm.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getstatuses">
<tt class="descname">getstatuses</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getstatuses" title="Permalink to this definition">¶</a></dt>
<dd>return the list of statuses for the specified userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getstatususers">
<tt class="descname">getstatususers</tt><big>(</big><em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getstatususers" title="Permalink to this definition">¶</a></dt>
<dd>return all users that have the specified status.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuser">
<tt class="descname">getuser</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuser" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuseremail">
<tt class="descname">getuseremail</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuseremail" title="Permalink to this definition">¶</a></dt>
<dd>get email of user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuserhosts">
<tt class="descname">getuserhosts</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuserhosts" title="Permalink to this definition">¶</a></dt>
<dd>return the userhosts associated with the specified user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuserpermits">
<tt class="descname">getuserpermits</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuserpermits" title="Permalink to this definition">¶</a></dt>
<dd>return permits of user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuserperms">
<tt class="descname">getuserperms</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuserperms" title="Permalink to this definition">¶</a></dt>
<dd>return permission of user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.getuserstatuses">
<tt class="descname">getuserstatuses</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.getuserstatuses" title="Permalink to this definition">¶</a></dt>
<dd>return the list of statuses for the specified user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.gotperm">
<tt class="descname">gotperm</tt><big>(</big><em>name</em>, <em>perm</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.gotperm" title="Permalink to this definition">¶</a></dt>
<dd>check if user has permission.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.gotpermit">
<tt class="descname">gotpermit</tt><big>(</big><em>name</em>, <em>permit</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.gotpermit" title="Permalink to this definition">¶</a></dt>
<dd>check if user permits something.  permit is a [who, what] list.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.gotstatus">
<tt class="descname">gotstatus</tt><big>(</big><em>name</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.gotstatus" title="Permalink to this definition">¶</a></dt>
<dd>check if user has status.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.gotuserhost">
<tt class="descname">gotuserhost</tt><big>(</big><em>name</em>, <em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.gotuserhost" title="Permalink to this definition">¶</a></dt>
<dd>check if user has userhost.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.make_owner">
<tt class="descname">make_owner</tt><big>(</big><em>userhosts</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.make_owner" title="Permalink to this definition">¶</a></dt>
<dd><p>see if owner already has a user account if not merge otherwise 
add.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>userhosts</em> (list or string) &#8211; userhosts to inititalize owner with</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.merge">
<tt class="descname">merge</tt><big>(</big><em>name</em>, <em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.merge" title="Permalink to this definition">¶</a></dt>
<dd><p>add userhosts to user with name.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><em>name</em> (string) &#8211; name of the user to merge with</li>
<li><em>userhost</em> (list .. list of userhosts) &#8211; userhosts to merge</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">boolean .. whether the merge succeeded</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.names">
<tt class="descname">names</tt><big>(</big><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.names" title="Permalink to this definition">¶</a></dt>
<dd><p>get names of all users.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">list .. list of usernames</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.permitted">
<tt class="descname">permitted</tt><big>(</big><em>userhost</em>, <em>who</em>, <em>what</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.permitted" title="Permalink to this definition">¶</a></dt>
<dd><p>check if (who,what) is in users permit list.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>userhost</em> (string) &#8211; userhost to check permits for</li>
<li><em>who</em> (string) &#8211; who to permit</li>
<li><em>what</em> (string) &#8211; what to allow</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.setemail">
<tt class="descname">setemail</tt><big>(</big><em>name</em>, <em>email</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.setemail" title="Permalink to this definition">¶</a></dt>
<dd>set email of user.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.size">
<tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.size" title="Permalink to this definition">¶</a></dt>
<dd>return nr of users.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.status">
<tt class="descname">status</tt><big>(</big><em>userhost</em>, <em>status</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.status" title="Permalink to this definition">¶</a></dt>
<dd>check if user with &lt;userhost&gt; has &lt;status&gt; set.</dd></dl>

<dl class="method">
<dt id="gozerlib.users.GozerUsers.usersearch">
<tt class="descname">usersearch</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.GozerUsers.usersearch" title="Permalink to this definition">¶</a></dt>
<dd><p>search for users with a userhost like the one specified.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>userhost</em> (string) &#8211; userhost to search for</td>
</tr>
<tr class="field"><th class="field-name">Return type:</th><td class="field-body">list .. list of (user.name, user.userhost) tuples</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="gozerlib.users.byname">
<tt class="descclassname">gozerlib.users.</tt><tt class="descname">byname</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#gozerlib.users.byname" title="Permalink to this definition">¶</a></dt>
<dd>get a users based on name.</dd></dl>

<dl class="function">
<dt id="gozerlib.users.getuser">
<tt class="descclassname">gozerlib.users.</tt><tt class="descname">getuser</tt><big>(</big><em>userhost</em><big>)</big><a class="headerlink" href="#gozerlib.users.getuser" title="Permalink to this definition">¶</a></dt>
<dd>get a user based on userhost.</dd></dl>

</div>
<div class="section" id="code">
<h2>code<a class="headerlink" href="#code" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre>  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901</pre></td><td class="code"><div class="highlight"><pre><span class="c"># gozerlib/users.py</span>
<span class="c">#</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot; bot users &quot;&quot;&quot;</span>

<span class="c">## gozerlib imports</span>

<span class="kn">from</span> <span class="nn">gozerlib.utils.xmpp</span> <span class="kn">import</span> <span class="n">stripped</span>
<span class="kn">from</span> <span class="nn">gozerlib.config</span> <span class="kn">import</span> <span class="n">ownercheck</span>

<span class="c">## google imports</span>

<span class="kn">from</span> <span class="nn">google.appengine.ext</span> <span class="kn">import</span> <span class="n">db</span>

<span class="c">## basic imports</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">types</span>
<span class="kn">import</span> <span class="nn">time</span>

<span class="k">class</span> <span class="nc">GozerUser</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Expando</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; gozerwave users model. &quot;&quot;&quot;</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">email</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">()</span>
    <span class="n">userhosts</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringListProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">perms</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringListProperty</span><span class="p">()</span>
    <span class="n">permits</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringListProperty</span><span class="p">()</span>
    <span class="n">statuses</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringListProperty</span><span class="p">()</span>
    <span class="n">password</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">()</span>

<span class="k">class</span> <span class="nc">GozerUserhost</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Expando</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; used to lookup userhost based on name. &quot;&quot;&quot;</span>

    <span class="n">name</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">userhost</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">StringProperty</span><span class="p">(</span><span class="n">required</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; get a user based on userhost. &quot;&quot;&quot;</span>
    
    <span class="n">uh</span> <span class="o">=</span> <span class="n">GozerUserhost</span><span class="o">.</span><span class="n">all</span><span class="p">()</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="s">&#39;userhost =&#39;</span><span class="p">,</span> <span class="n">userhost</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">uh</span><span class="p">:</span>
        <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;no userhost found for </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">userhost</span><span class="p">)</span>
        <span class="k">return</span>
    <span class="n">user</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GozerUser WHERE name = :1&quot;</span><span class="p">,</span> <span class="n">uh</span><span class="o">.</span><span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">user</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;no user found for </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">uh</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">byname</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; get a users based on name. &quot;&quot;&quot;</span>
    <span class="n">user</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GozerUser WHERE name = :1&quot;</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
    <span class="k">return</span> <span class="n">user</span>

<span class="k">class</span> <span class="nc">GozerUsers</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">         google datbase engine backed users.</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c">### Misc. Functions</span>
    <span class="k">def</span> <span class="nf">size</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return nr of users.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">result</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">GqlQuery</span><span class="p">(</span><span class="s">&quot;SELECT * FROM GozerUser&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="mf">1000</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
        

    <span class="k">def</span> <span class="nf">getuser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            get names of all users.</span>

<span class="sd">            :rtype: list .. list of usernames</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">n</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">GozerUser</span><span class="o">.</span><span class="n">all</span><span class="p">()]</span>

    <span class="k">def</span> <span class="nf">merge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">             add userhosts to user with name.</span>

<span class="sd">             :param name: name of the user to merge with</span>
<span class="sd">             :type name: string</span>
<span class="sd">             :param userhost: userhosts to merge </span>
<span class="sd">             :type userhost: list .. list of userhosts</span>
<span class="sd">             :rtype: boolean .. whether the merge succeeded</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">userhost</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">uh</span> <span class="o">=</span> <span class="n">GozerUserhost</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="o">=</span><span class="n">userhost</span><span class="p">)</span>
                <span class="n">uh</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> merged with </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="n">name</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">usersearch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            search for users with a userhost like the one specified.</span>

<span class="sd">            :param userhost: userhost to search for</span>
<span class="sd">            :type userhost: string</span>
<span class="sd">            :rtype: list .. list of (user.name, user.userhost) tuples</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="p">[(</span><span class="n">u</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">userhosts</span><span class="p">)</span> <span class="k">for</span> <span class="n">u</span> <span class="ow">in</span> <span class="n">GozerUser</span><span class="o">.</span><span class="n">all</span><span class="p">()]</span>

    <span class="c">### Check functions</span>
    <span class="k">def</span> <span class="nf">exists</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            see if user with &lt;name&gt; exists.</span>

<span class="sd">            :param name: name of the user</span>
<span class="sd">            :rtype: boolean</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">a</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">a</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">allowed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">perms</span><span class="p">,</span> <span class="n">log</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user with userhosts is allowed to execute perm command.</span>

<span class="sd">            :param userhost: userhost to check</span>
<span class="sd">            :type userhost: string</span>
<span class="sd">            :param perms: the permissions to check            </span>
<span class="sd">            :type perms: list</span>
<span class="sd">            :param log: whether the check should be logged</span>
<span class="sd">            :type log: boolean</span>
<span class="sd">            :rtype: list .. list of matching permissions or None</span>
<span class="sd"> </span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">ownercheck</span><span class="p">(</span><span class="n">userhost</span><span class="p">):</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">userhost</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="p">[</span><span class="n">userhost</span><span class="p">,</span> <span class="p">],</span> <span class="p">[</span><span class="s">&#39;USER&#39;</span><span class="p">,</span> <span class="s">&#39;OPER&#39;</span><span class="p">])</span>

            <span class="k">return</span> <span class="p">[</span><span class="s">&#39;USER&#39;</span><span class="p">,</span> <span class="s">&#39;OPER&#39;</span><span class="p">]</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">type</span><span class="p">(</span><span class="n">perms</span><span class="p">)</span> <span class="o">==</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">:</span>
            <span class="n">perms</span> <span class="o">=</span> <span class="p">[</span><span class="n">perms</span><span class="p">,</span> <span class="p">]</span>

        <span class="k">if</span> <span class="s">&#39;ANY&#39;</span> <span class="ow">in</span> <span class="n">perms</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">[</span><span class="s">&#39;ANY&#39;</span><span class="p">,</span> <span class="p">]</span>

        <span class="n">res</span> <span class="o">=</span> <span class="bp">None</span>
        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">log</span><span class="p">:</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> userhost denied&#39;</span> <span class="o">%</span> <span class="n">userhost</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">res</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">uperms</span> <span class="o">=</span> <span class="n">set</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">)</span>
            <span class="n">sperms</span> <span class="o">=</span> <span class="n">set</span><span class="p">(</span><span class="n">perms</span><span class="p">)</span>
            <span class="n">intersection</span> <span class="o">=</span> <span class="n">sperms</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">uperms</span><span class="p">)</span>
            <span class="n">res</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">intersection</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">None</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">res</span> <span class="ow">and</span> <span class="n">log</span><span class="p">:</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> perm </span><span class="si">%s</span><span class="s"> denied&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">perms</span><span class="p">)))</span>

        <span class="k">if</span> <span class="n">res</span> <span class="ow">and</span> <span class="n">log</span><span class="p">:</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;allowed </span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s"> perm&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">perms</span><span class="p">)))</span>

        <span class="k">return</span> <span class="n">res</span>

    <span class="k">def</span> <span class="nf">permitted</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">who</span><span class="p">,</span> <span class="n">what</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if (who,what) is in users permit list.</span>

<span class="sd">            :param userhost: userhost to check permits for</span>
<span class="sd">            :type userhost: string</span>
<span class="sd">            :param who: who to permit</span>
<span class="sd">            :type who: string</span>
<span class="sd">            :param what: what to allow</span>
<span class="sd">            :type what: string</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>
        <span class="n">res</span> <span class="o">=</span> <span class="bp">False</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="p">:</span>
                <span class="n">res</span> <span class="o">=</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="n">res</span>

    <span class="k">def</span> <span class="nf">status</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user with &lt;userhost&gt; has &lt;status&gt; set.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>
        <span class="n">res</span> <span class="o">=</span> <span class="bp">False</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">:</span>
                <span class="n">res</span> <span class="o">=</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="n">res</span>

    <span class="k">def</span> <span class="nf">gotuserhost</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user has userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">userhost</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">gotperm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user has permission.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">perm</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">perms</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">gotpermit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">permit</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user permits something.  permit is a [who, what] list. </span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">permit</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">permits</span>

        <span class="k">return</span> <span class="s">&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">gotstatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            check if user has status.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">statuses</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="c">### Get Functions</span>
    <span class="k">def</span> <span class="nf">getname</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            get name of user belonging to &lt;userhost&gt;.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>

        <span class="k">return</span> <span class="s">&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">gethosts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            return the userhosts of the user associated with the </span>
<span class="sd">            specified userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="p">)</span>

        <span class="k">return</span> <span class="p">[]</span>
    
    <span class="k">def</span> <span class="nf">getemail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return the email of the specified userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="p">:</span>
                <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="p">)</span>

        <span class="k">return</span> <span class="s">&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">getperms</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return permissions of user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">)</span>

        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">getpermits</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return permits of the specified userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="p">)</span>

        <span class="k">return</span> <span class="p">[]</span>

    <span class="k">def</span> <span class="nf">getstatuses</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return the list of statuses for the specified userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getuserhosts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return the userhosts associated with the specified user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getuseremail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            get email of user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="p">:</span>
                <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getuserperms</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return permission of user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getuserpermits</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
 
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return permits of user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getuserstatuses</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return the list of statuses for the specified user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">getpermusers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return all users that have the specified perm.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">user</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">user</span> <span class="ow">in</span> <span class="n">GozerUser</span><span class="o">.</span><span class="n">all</span><span class="p">()</span> <span class="k">if</span> <span class="n">perm</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">getstatususers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            return all users that have the specified status.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="p">[</span><span class="n">user</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">user</span> <span class="ow">in</span> <span class="n">GozerUser</span><span class="o">.</span><span class="n">all</span><span class="p">()</span> <span class="k">if</span> <span class="n">status</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">]</span>

    <span class="c">### Set Functions</span>
    <span class="k">def</span> <span class="nf">setemail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">email</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            set email of user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="n">email</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="c">### Add functions</span>
    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">userhosts</span><span class="p">,</span> <span class="n">perms</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add an user. session argument is provided by @trans</span>

<span class="sd">            :param name: name of the user</span>
<span class="sd">            :type name: string</span>
<span class="sd">            :param userhosts: userhosts to add</span>
<span class="sd">            :type userhosts: list .. list of userhosts</span>
<span class="sd">            :param perms: the permissions to add</span>
<span class="sd">            :type perms: list .. list of permissions</span>


<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">userhosts</span><span class="p">)</span> <span class="o">!=</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">:</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;i need a list of userhosts&#39;</span><span class="p">)</span>
            <span class="k">return</span> <span class="bp">False</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">newuser</span> <span class="o">=</span> <span class="n">GozerUser</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">)</span>
            <span class="n">newuser</span><span class="o">.</span><span class="n">userhosts</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">userhosts</span><span class="p">)</span>
            <span class="n">newuser</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">perms</span><span class="p">)</span>
            <span class="n">newuser</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>

            <span class="k">for</span> <span class="n">userhost</span> <span class="ow">in</span> <span class="n">userhosts</span><span class="p">:</span>
                <span class="n">newuserhost</span> <span class="o">=</span> <span class="n">GozerUserhost</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="o">=</span><span class="n">userhost</span><span class="p">)</span>
                <span class="n">newuserhost</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>

            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s"> added to user database&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">userhosts</span><span class="p">,</span> <span class="n">perms</span><span class="p">))</span>

        <span class="k">return</span> <span class="bp">True</span>

    <span class="k">def</span> <span class="nf">addperm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add the specified perm to the userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">perm</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> perm </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="n">perm</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">addpermit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">permit</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add the given [who, what] permit to the given userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">permit</span>
            <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> permit </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">userhost</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">addstatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add status to given userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> status </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">status</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">adduserhost</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">newuserhost</span> <span class="o">=</span> <span class="n">GozerUserhost</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="o">=</span><span class="n">userhost</span><span class="p">)</span>
            <span class="n">newuserhost</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>

            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> (</span><span class="si">%s</span><span class="s">) added to userhosts&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">adduseremail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">email</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add email to specified user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">email</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> email </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">email</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

    <span class="k">def</span> <span class="nf">adduserperm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add permission.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">perm</span> <span class="o">=</span> <span class="n">perm</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
            <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">perm</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> perm </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">perm</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">adduserpermit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">who</span><span class="p">,</span> <span class="n">permit</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            add (who, what) permit tuple to specified user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">permit</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> permit </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">adduserstatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            add status to given user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> status </span><span class="si">%s</span><span class="s"> added&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">status</span><span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>


    <span class="c">### Delete functions</span>
    <span class="k">def</span> <span class="nf">delemail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">email</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete email from userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">delperm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete perm from userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">perm</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>
            
    <span class="k">def</span> <span class="nf">delpermit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">permit</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete permit from userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">permit</span>

            <span class="k">if</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">delstatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhost</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete status from userhost.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">getuser</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">st</span> <span class="o">=</span> <span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">st</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">st</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">delete</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot; </span>
<span class="sd">            delete user with name. </span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">deluserhost</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete the userhost entry.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">userhost</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">userhosts</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">userhost</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> userhost </span><span class="si">%s</span><span class="s"> deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">userhost</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">deluseremail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">email</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete email.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">email</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">email</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">email</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> email </span><span class="si">%s</span><span class="s"> deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">email</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">deluserperm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">             delete permission.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">perm</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> perm </span><span class="si">%s</span><span class="s"> deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">deluserpermit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">permit</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete permit.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">permit</span>

            <span class="k">if</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">permits</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> permit </span><span class="si">%s</span><span class="s"> deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">deluserstatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">status</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete the status from the given user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">st</span> <span class="o">=</span> <span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">st</span> <span class="ow">in</span> <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="p">:</span>
                <span class="n">user</span><span class="o">.</span><span class="n">statuses</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">status</span><span class="p">)</span>
                <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
                <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> status </span><span class="si">%s</span><span class="s"> deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">st</span><span class="p">))</span>
                <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">delallemail</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            Delete all emails of the specified user.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">user</span> <span class="o">=</span> <span class="n">byname</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">user</span><span class="p">:</span>
            <span class="n">user</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
            <span class="n">user</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
            <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> emails deleted&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="p">))</span>
            <span class="k">return</span> <span class="bp">True</span>

        <span class="k">return</span> <span class="bp">False</span>

    <span class="k">def</span> <span class="nf">delpermall</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">perm</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            delete permission from all users.</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">users</span> <span class="o">=</span> <span class="n">GozerUser</span><span class="o">.</span><span class="n">all</span><span class="p">()</span><span class="o">.</span><span class="n">fetch</span><span class="p">()</span>

        <span class="k">for</span> <span class="n">user</span> <span class="ow">in</span> <span class="n">users</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">user</span><span class="o">.</span><span class="n">name</span> <span class="o">!=</span> <span class="s">&#39;owner&#39;</span><span class="p">:</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">user</span><span class="o">.</span><span class="n">perms</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">perm</span><span class="p">)</span>

                <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                    <span class="k">pass</span>
        <span class="n">users</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">True</span>

    <span class="k">def</span> <span class="nf">make_owner</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userhosts</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            see if owner already has a user account if not merge otherwise </span>
<span class="sd">            add.</span>

<span class="sd">            :param userhosts: userhosts to inititalize owner with</span>
<span class="sd">            :type userhosts: list or string</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">owner</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">userhosts</span><span class="p">)</span> <span class="o">!=</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">:</span>
            <span class="n">owner</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">userhosts</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">owner</span> <span class="o">=</span> <span class="n">userhosts</span>

        <span class="k">for</span> <span class="n">userhost</span> <span class="ow">in</span> <span class="n">owner</span><span class="p">:</span>
            <span class="n">username</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getname</span><span class="p">(</span><span class="nb">unicode</span><span class="p">(</span><span class="n">userhost</span><span class="p">))</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="s">&#39;owner&#39;</span><span class="p">,</span> <span class="nb">unicode</span><span class="p">(</span><span class="n">userhost</span><span class="p">)):</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;owner&#39;</span><span class="p">,</span> <span class="p">[</span><span class="nb">unicode</span><span class="p">(</span><span class="n">userhost</span><span class="p">),</span> <span class="p">],</span> <span class="p">[</span><span class="s">&#39;USER&#39;</span><span class="p">,</span> <span class="s">&#39;OPER&#39;</span><span class="p">])</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">users</a><ul>
<li><a class="reference external" href="#module-gozerlib.users">description</a></li>
<li><a class="reference external" href="#code">code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="tests.html"
                                  title="previous chapter">tests</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="persist/index.html"
                                  title="next chapter">gozerlib.persist</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/gozerlib/users.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="persist/index.html" title="gozerlib.persist"
             >next</a> |</li>
        <li class="right" >
          <a href="tests.html" title="tests"
             >previous</a> |</li>
        <li><a href="../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Bart Thate.
      Last updated on Nov 14, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>